package com.zqx.tokenauth.vo;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ResultVO
 * 此类与ResultVO本质作用相同
 */
@Data
public class ResultVO implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long code = 0L; // code
    private String msg = ""; // msg
    private long count; // count
    private Object data; // data

    public ResultVO() {
    }


    public ResultVO(Object data) {
        this.data = data;
    }

    public ResultVO(Long code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultVO(Long code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultVO(Long code, String msg, long count, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Map<String, Object> toMap() {
        HashMap<String, Object> result = new HashMap<String, Object>();
        result.put("code", code);
        result.put("msg", msg);
        result.put("data", data);
        result.put("count",count);
        return result;
    }

    public static ResultVO fail(String msg) {
        ResultVO jsonData = new ResultVO();
        jsonData.code = 1L;
        jsonData.msg = msg;
        return jsonData;
    }

    public Long getCode() {
        return code;
    }

    public void setCode(Long code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}